package yz.mr.OutPut;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class OutputMapper extends Mapper<LongWritable, Text, NullWritable,OutputStudent> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, NullWritable, OutputStudent>.Context context) throws IOException, InterruptedException {
        String[] sp = value.toString().split("\t");
        String id = sp[0];
        String other = sp[1];
        String[] split = other.split(",");
        OutputStudent student = new OutputStudent(id, split[0], split[1], split[2], split[3], Integer.parseInt(split[4]));
        context.write(NullWritable.get(),student);

    }
}
